home *** CD-ROM | disk | FTP | other *** search
- /************************************************************/
- /* */
- /* CDragPane Code from Chapter Six of */
- /* */
- /* *** The Macintosh Programming Primer *** */
- /* */
- /* Copyright 1990, Dave Mark */
- /* */
- /* This program demonstrates specific Mac programming */
- /* techniques. */
- /* */
- /************************************************************/
-
- #include "CStarterPane.h"
- #include "CDragPane.h"
-
- Boolean gIsScrolling = FALSE;
-
-
- /******************************** IDragPane *********/
-
- void CDragPane::IDragPane( Point corner,
- int height,
- int width,
- int patNum,
- CView *anEnclosure,
- CBureaucrat *aSupervisor )
- {
- LongRect r;
-
- /* Restrict the pane to be within the bounds of the panorama. */
-
- ((CPanorama *)anEnclosure)->GetBounds(&r);
-
- if ((corner.h + width) > r.right)
- corner.h -= corner.h + width - r.right;
-
- if ((corner.v + height) > r.bottom)
- corner.v -= corner.v + height - r.bottom;
-
- IPane( anEnclosure, aSupervisor, width, height,
- corner.h, corner.v, sizFIXEDSTICKY, sizFIXEDSTICKY );
-
- patNumber = patNum;
-
- SetWantsClicks( TRUE );
- Refresh();
- }
-
-
- /******************************** Draw *********/
-
- void CDragPane::Draw( Rect *rPtr )
- {
- if ( ! gIsScrolling )
- {
- Prepare();
-
- switch( patNumber )
- {
- case 0:
- PenPat( ltGray );
- break;
- case 1:
- PenPat( gray );
- break;
- case 2:
- PenPat( dkGray );
- break;
- default:
- PenPat( black );
- break;
- }
-
- PaintRect( rPtr );
- }
- }
-
-
- /******************************** DoClick *********/
-
- void CDragPane::DoClick( Point hitPt, short modifierKeys, long when )
- {
- Rect r;
- Rect endLocation;
- LongRect longR;
-
- /*r = frame; Old */
- FrameToQDR( &frame, &r );/*NEW*/
- EraseRect( &r );
- QDToLongRect(&r,&longR);
- FrameToEnclR(&longR);
- LongToQDRect( &longR, &r );
-
- ((CStarterPane *)itsEnclosure)->DoDrag( width, height,
- hitPt, r, &endLocation );
-
- Place(endLocation.left, endLocation.top, TRUE);
- }